import Mock from "mockjs";
import qs from 'qs';
//提交留言
Mock.mock("/api/message", "post", {
  code: 0,
  msg: "",
  data: {
    id: '@guid',
    nickname: "@cname",
    content: "@cparagraph(1, 10)",
    createDate: Date.now(),
    date: '@DATETIME("yyyy-MM-dd HH:mm:ss")',
    "avatar|1": [
      "@image(300x250, @color, #fff, message)",
    ],
  }
})

//获取留言
Mock.mock(/\/api\/message(\?.+)?$/, "get", function (options) {
  const query = qs.parse(options.url);
  return Mock.mock({
    code: 0,
    msg: '',
    data: {
      "total|60": 0,
      [`rows|${query.limit}`]: [{
        id: "@guid",
        nickname: "@cname",
        content: "@cparagraph(1, 10)",
        createDate: Date.now(),
        date: '@DATETIME("yyyy-MM-dd HH:mm:ss")',
        "avatar|1": [
          "@image(300x250, @color, #fff, message)"
        ],
      }]
    }
  })
})